<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>

<div class="layui-form layuimini-form" lay-filter="userEditFormFilter">

    <input type="hidden" name="oldUserId" value="">
    <div class="layui-form-item">
        <label class="layui-form-label required">用户编号</label>
        <div class="layui-input-block">
            <input type="text" name="userId" lay-verify="required" lay-reqtext="用户编号不能为空" placeholder="请输入用户编号"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户姓名</label>
        <div class="layui-input-block">
            <input type="text" name="userName" lay-verify="required" lay-reqtext="用户姓名不能为空" placeholder="请输入用户姓名"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">登录账号</label>
        <div class="layui-input-block">
            <input type="text" name="account"  lay-reqtext="登录账号不能为空" placeholder="请输入登录账号"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">登录密码</label>
        <div class="layui-input-block">
            <input type="text" name="password"  lay-reqtext="登录密码不能为空" placeholder="请输入登录密码"
                   value=""
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>

<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>

    var data;
    function child(data){
        this.data = data;
    }

    layui.use(['form','element'], function () {
        var form = layui.form,
            layer = layui.layer,
            element = layui.element,
            $ = layui.$;

        //初始化表单
        form.val("userEditFormFilter", {
            "oldUserId":data.userId,
            "userId": data.userId,
            "userName": data.userName,
            "account": data.account,
            "password":data.password
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //打印表单数据
            console.log(data.field);
            $.post("/wfx_manager/user/editUser",
                form.val("userEditFormFilter"),
                function (res) {
                    if (res.flag) {
                        //获取iframe的唯一标识
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        //关闭iframe窗口
                        parent.layer.close(iframeIndex);
                        //将表单中的数据传递到villagelist
                        parent.parent(form.val("userEditFormFilter"));
                    }
                });
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);

            return false;
        });



    });
</script>
</body>
</html>